<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>选择项目</title>
    <script src="/scripts/boot.js"></script>
</head>
<body class="bg-white">
<div id="viewForm">
    <table class="table-bg" border="0" cellpadding="1" cellspacing="1" style="width:100%; height: 300px; table-layout:fixed;">
        <tr>
            <td>
                <ul id="tree2" class="mini-tree" url="/tree/itemInfo/findTreeToBuild" style="width:350px;padding:5px;"
                showTreeIcon="true" textField="name" idField="id" parentField="pid" resultAsTree="false"
                showCheckBox="true" checkRecursive="true" expandOnLoad="4"
                onbeforenodecheck="view.onBeforeNodeCheck" allowSelect="false" enableHotTrack="false">
                </ul>
            </td>
        </tr>
    </table>
    <div class="chose-toolbar">
        <a class="chose-button" onclick="CloseWindow('close')">取消</a>
        <a class="chose-button save-button" onclick="view.save()">确认</a>
    </div>
</div>
<script type="text/javascript">
    var post_flag,form,state,datas;
    var view = {
        init: function () {
            post_flag = false; //设置一个对象来控制是否进入AJAX过程
            mini.parse();
            form = new mini.Form("#viewForm");
        },
        //保存
        save: function () {
            form.validate();
            if (form.isValid() == false) return;
            if (post_flag) return;
            common.loading("保存中");
            var data = form.getData(true);//获取表单多个控件的数据
            post_flag = true;
            $.ajax({
                url: (state=="new"?"/keyPlanNode/save":"/keyPlanNode/edit?id=" + data.id),
                type: "post",
                data: data,
                success: function (msg) {
                    post_flag = false;
                    mini.open({
                        url: "/planning/keyPoint/plannList.html",
                        title: (opt=="edit"?"编辑":"新增")+"计划", width: 1100, height: 700,
                        onload: function () {
                            var data = {"id": row.id,"state":opt};
                            var iframe = this.getIFrameEl();
                            iframe.contentWindow.view.SetData(data);
                        },
                        ondestroy: function (action) {
                            // mini.get("datagrid1").reload();
                        }
                    });
                    common.unmask();
                },
                error: function (errorMsg) {
                    post_flag = false;
                    common.unmask();
                }
            });
        },
        onBeforeNodeCheck: function(e) {
        var tree = e.sender;
        var node = e.node;
        if (tree.hasChildren(node)) {
            //e.cancel = true;
        }
    }
    };
    view.init();
</script>
</body>
</html>